//
//  TroopForm.hpp
//  fingeradvanture
//
//  Created by shuaibincheng on 16/5/7.
//
//

#ifndef TroopForm_hpp
#define TroopForm_hpp
#include "cocos2d.h"
#include "MonsterDen.hpp"
#include "TroopStyle.hpp"
#include "TroopAction.hpp"

USING_NS_CC;

enum TroopFormType
{
    TROOP_INVALID_TROOP_FORM,   //非法怪物组
    TROOP_SINGLE_FORM,          //由单个怪物组成一组
    TROOP_LINE_FORM,            //线型怪物组
    TROOP_CROSS_FORM,           //十字型怪物组
    TROOP_SQUARE_FORM,          //方型怪物组
    TROOP_HEXAGON_FORM          //六角型怪物组
};

class TroopForm
{
private:
    int maxNumOfMonsterTypes;    //该队形至多支持的monser种类数
    int maxNumOfMonster;    //该队形包含monster最大数目
    int minNumOfMonster;    //该队形包含monster最小数目
    
    int numOfMonster;   //当前队形中包含的怪物个数
    int numOfMonsterType; //当前队形中包含的怪物种类数
    
    TroopStyle *style;
    TroopAction *action;
protected:
    Size troopSize;  //队伍占用空间的长、宽大小
    Size troopVisibleSize; //队伍可见的空间大小
    Vector<Node *> *members; //队伍中怪物集合,根据加入的次序排列，怪物加入的次序很重要，决定了怪物的空间位置
    
public:
    
    TroopForm(int numOfType, int maxNumOfMonster, int minNumOfMonster);
    ~TroopForm()
    {
        CC_SAFE_DELETE(style);
        CC_SAFE_DELETE(members);
        CC_SAFE_DELETE(action);
    }
    
    virtual int getMaxNumOfMonsterTypes() const;
    
    inline int getMaxNumOfMonster() const { return maxNumOfMonster;}
    inline void setMaxNumOfMonster(int num){ maxNumOfMonster = num;}
    
    inline int getMinNumOfMonster() const { return minNumOfMonster;}
    inline void setMinNumOfMonster(int num){ minNumOfMonster = num;}
    
    inline void setNumOfMonster(int num){ numOfMonster = num; }
    inline int getNumOfMonster() const { return numOfMonster; }
    inline void setNumOfMonsterType(int num) { numOfMonsterType = num; }
    inline int getNumOfMonsterType() const { return numOfMonsterType; }
    
    inline Size getTroopSize() const { return troopSize; }
    inline Size getVisibleSize() const { return troopVisibleSize; }
    
    inline void setStyle(TroopStyle *style) { this->style = style; }
    inline TroopStyle *getStyle() const { return this->style; }
    
    inline void setAction(TroopAction *action) { this->action = action; }
    inline TroopAction *getAction() const { return this->action; }
    
    virtual void join(Node *monster); //将monster加入队伍
    virtual void group();  //整理队伍
    virtual void train();  //训练队伍
    
    Vector<Node *> rollout(){ return *members; }
    
    virtual int numOfMonsterForType(const MonsterType &type);  //确定某种类型的monster在队伍中的个数
    virtual std::vector<TroopStyleType> allowedTroopStyles();//队伍允许出现的风格
    virtual std::vector<TroopActionStyle> allowedTroopActionStyle(); //队伍允许出现的动作

    
    virtual float marginLeft();//队伍距离左侧边界的距离
    virtual float marginRight();//队伍距离右侧边界的距离
public:
    static TroopForm *getTroopFormByType(TroopFormType type);
};

#endif /* TroopForm_hpp */
